//app.js
App({
    onLaunch: function () {
      //调用API从本地缓存中获取数据
      var logs = wx.getStorageSync('logs') || []
      logs.unshift(Date.now())
      wx.setStorageSync('logs', logs)
    },
    globalData: {
      userInfo: null
    },//公共请求地址
    config: function () {
      var url = "https://m.api.tailorism.com/index.php/";
      return url;
    },//验证手机号
    phone_number_reg: function (phone_number) {
      var reg = /^1(3|4|5|7|8|9)\d{9}$/;
      if (!reg.test(phone_number)) {
        return false
      } else {
        return true;
      }
    },
    to_time: function (value) {
      var date = new Date(parseInt(value) * 1000);
      var seperator1 = "/";
      var seperator2 = ":";
      var month = date.getMonth() + 1;
      var strDate = date.getDate();
      if (month >= 1 && month <= 9) {
          month = "0" + month;
      }
      if (strDate >= 0 && strDate <= 9) {
          strDate = "0" + strDate;
      }
      var hour = date.getHours();
      if (hour >= 0 && hour <= 9) {
          hour = "0" + hour;
      }
      var minute = date.getMinutes();
      if (minute >= 0 && minute <= 9) {
          minute = "0" + minute;
      }
      var second = date.getSeconds();
      if (second >= 0 && second <= 9) {
          second = "0" + second;
      }
      var currentdate = date.getFullYear() + seperator1 + month + seperator1 + strDate + " " + hour + seperator2 + minute + seperator2 + second;
      return currentdate;
    },//获取用户的当前设置。
    open_setting:function(){
      wx.getSetting({
        success: function (res) {
          if (!res.authSetting['scope.userInfo']) {
            // 调起客户端小程序设置界面，返回用户设置的操作结果
            wx.openSetting({
              success: function (res) {
                  
              },
              fail: function (res) {

              },
              complete: function (res) {

              }
            })
          }
        }
      })
    }
})